import http from "@/api";

import { PORT1 } from "@/api/config/servicePort";

import { MerakXTableQuery } from "@/components/MerakXTable";

export interface OptionType {
  value: string | number;
  label: string;
  [x: string]: any;
}

// 保存申请公司
export const saveCompany = (data: Record<string, any>) =>
  http.post(`${PORT1}/km/import-company/edit`, { ...data }, { loading: false });

// 更新公司状态
export const updateStatus = (data: Record<string, any>) =>
  http.post(`${PORT1}/km/import-company/update-status`, { ...data }, { loading: false });

// 验证字段
export const validField = (data: Record<string, any>) =>
  http.post(`${PORT1}/km/import-company/verify`, { ...data }, { loading: false });

// 获取关联公司选项
export const getFactoryOptions = () => http.post<OptionType[]>(`${PORT1}/km/import-company/form-select`, {}, { loading: false });

// 获取GCP表头
export const getGCPTableColumns = (data: { import_company_id: string | number; [x: string]: any }) =>
  http.post<MerakXTableQuery.Columns>(`${PORT1}/km/import-company/gcp-field`, { ...data }, { loading: false });

// 获取GCP数据
export const getGCPTableData = (data: Record<string, any>) =>
  http.post<{ table_data: MerakXTableQuery.Records; [k: string]: any }>(
    `${PORT1}/km/import-company/gcp-list`,
    { ...data },
    { loading: false }
  );

// 保存GCP数据
export const saveGCP = (data: Record<string, any>) =>
  http.post(`${PORT1}/km/import-company/gcp-update`, { ...data }, { loading: false });
